<template>
  <div class="block">
    <h2>可用金额：</h2>
    <span class="available">￥{{ availableAmount }}</span>
    <el-popover placement="bottom" width="200" trigger="click">
      <div style="line-height: 30px">账户金额：￥{{ accountAmount }}</div>
      <div style="line-height: 30px">锁定金额：￥{{ lockAmount }}</div>
      <div style="line-height: 30px">可用金额：￥{{ availableAmount }}</div>
      <el-button slot="reference" type="text" title="详情">
        <i class="el-icon-tickets"></i
      ></el-button>
    </el-popover>
    <div class="refresh">
      <el-button slot="reference" type="text" title="刷新" @click="getMoney">
        <i class="el-icon-refresh"></i
      ></el-button>
    </div>
  </div>
</template>

<script>
import baseView from "@/views/base";
import { utils } from "hi-ui";
import user from "@/api/user";

export default {
  name: "blanace",
  extends: baseView,
  components: {},
  data() {
    return {
      //账户金额
      accountAmount: 0,
      //锁定金额
      lockAmount: 0,
      //可用金额
      availableAmount: 0,
    };
  },
  computed: {},
  watch: {},
  methods: {
    getMoney() {
      // this.availableAmount = 0;
      user.getAccount().then((res) => {
        if (res.dataPack == 0) return;
        this.accountAmount = (res.dataPack[0].fBalance / 100).toFixed(2);
        this.lockAmount = (res.dataPack[0].fFrozenMoney / 100).toFixed(2);
        this.availableAmount = (res.dataPack[0].fAvailable / 100).toFixed(2);
      });
    },
  },

  mounted() {},
  created() {
    this.getMoney();
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.block {
  display: flex;
  align-items: center;
  // justify-content: space-between;
  padding: 0 20px;
  height: 100%;
  * {
    margin: 0;
    padding: 0;
  }
  h2 {
    margin-left: 20px;
    font-size: 17px;
    font-weight: bold;
  }
  .available {
    font-size: 15px;
  }
}
</style>
